﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;


namespace CleanDrive
{
    /// <summary>
    /// GIT Test
    /// </summary>
    class Program
    {
        static String drive = @"D:\prova";

        static List<string> safeDir = new List<string>();

        /// <summary>
        /// Inizializza la lista dei file da NON CANCELLARE
        /// </summary>
        static void initSafeDir()
        {

            String[] aLista = 
                    {
                        "Automazione",
                        "Biennio",
                        "Elettronica",
                        "Immagini ISO",
                        "immagini_iso",
                        "Informatica",
                        "LiceoST",
                        "Meccanica",
                        "Sirio"
                    };


            foreach (var item in aLista)
            {
                safeDir.Add((drive + "\\" + item).ToUpper());
            }
        }

        /// <summary>
        /// Elimina cartelle e file non consentiti
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            String[] allDir = Directory.GetDirectories(drive);

            initSafeDir();

            foreach (var item in allDir)
            {
                String nomeFile = item.ToUpper();
                if (safeDir.IndexOf(nomeFile) < 0)
                {
                    try
                    {
                        Directory.Delete(nomeFile, true);
                    }
                    catch (Exception)
                    {

                    }
                }
            }
        }
    }
}
